package com.ruoyi.bantong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bantong.domain.BtUserScoreRecord;
import com.ruoyi.bantong.service.IBtUserScoreRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户版通分兑换记录Controller
 * 
 * @author laohei
 * @date 2021-02-20
 */
@RestController
@RequestMapping("/bantong/scoreRecord")
public class BtUserScoreRecordController extends BaseController
{
    @Autowired
    private IBtUserScoreRecordService btUserScoreRecordService;

    /**
     * 查询用户版通分兑换记录列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(BtUserScoreRecord btUserScoreRecord)
    {
        startPage();
        List<BtUserScoreRecord> list = btUserScoreRecordService.selectBtUserScoreRecordList(btUserScoreRecord);
        return getDataTable(list);
    }

    /**
     * 导出用户版通分兑换记录列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:export')")
    @Log(title = "用户版通分兑换记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BtUserScoreRecord btUserScoreRecord)
    {
        List<BtUserScoreRecord> list = btUserScoreRecordService.selectBtUserScoreRecordList(btUserScoreRecord);
        ExcelUtil<BtUserScoreRecord> util = new ExcelUtil<BtUserScoreRecord>(BtUserScoreRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取用户版通分兑换记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:query')")
    @GetMapping(value = "/{ucrId}")
    public AjaxResult getInfo(@PathVariable("ucrId") Integer ucrId)
    {
        return AjaxResult.success(btUserScoreRecordService.selectBtUserScoreRecordById(ucrId));
    }

    /**
     * 新增用户版通分兑换记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:add')")
    @Log(title = "用户版通分兑换记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BtUserScoreRecord btUserScoreRecord)
    {
        return toAjax(btUserScoreRecordService.insertBtUserScoreRecord(btUserScoreRecord));
    }

    /**
     * 修改用户版通分兑换记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:edit')")
    @Log(title = "用户版通分兑换记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BtUserScoreRecord btUserScoreRecord)
    {
        return toAjax(btUserScoreRecordService.updateBtUserScoreRecord(btUserScoreRecord));
    }

    /**
     * 删除用户版通分兑换记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:remove')")
    @Log(title = "用户版通分兑换记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ucrIds}")
    public AjaxResult remove(@PathVariable Integer[] ucrIds)
    {
        return toAjax(btUserScoreRecordService.deleteBtUserScoreRecordByIds(ucrIds));
    }
}
